package niofile;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

public class FileLineDataHandler implements DataProcessHandler{
	private String encode = "GBK"; 
	@Override 
	public void process(byte[] data) { 
		try { 
			System.out.println(new String(data,encode).toString()); 
		} catch (UnsupportedEncodingException e) { 
			e.printStackTrace(); 
		} 
	} 
	
	public static void main(String[] args) {
		/*FileReader fileReader = new FileReader("",100,3); 
		fileReader.registerHanlder(new FileLineDataHandler()); 
		fileReader.startRead(); */
		String s = "[{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}]";
		JSON j = JSON.parseArray(s);
		System.out.println(j.toJSONString());
		JSONArray ja = JSONArray.parseArray(s);
		Object[] o = ja.toArray();
		List ls = new ArrayList<>(Arrays.asList(o));
		for (Object object : ls) {
			System.out.println(object.toString());
		}
	}
}